package com;

import java.util.ArrayList;
import java.util.List;

import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.IPing;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import com.netflix.loadbalancer.Server;


public class IRuleDemo {
    public static void main(String[] args){
    	BaseLoadBalancer loadBalancer = new BaseLoadBalancer();
    	
    	IRule rule = new RoundRobinRule();
    	loadBalancer.setRule(rule);
    	
    	List<Server> myServers = new ArrayList<Server>();
    	Server s1 = new Server("ekserver1",8080);
    	Server s2 = new Server("ekserver2",8080);
    	Server s3 = new Server("ekserver3",8080);
    	myServers.add(s1);
    	myServers.add(s2);
    	myServers.add(s3);
    	
    	loadBalancer.addServers(myServers);
    	
    	for(int i=0;i<10;i++)
    	{
    		Server s = loadBalancer.chooseServer(null);
    		System.out.println(s.getHost() + ":" + s.getPort());    		
    	}
    	
    }
}
